package weaver.interfaces.jjy.duss.util;

import com.sap.conn.jco.ext.DestinationDataProvider;
import com.sap.mw.jco.JCO;

import java.util.Properties;

public class saptest {

    public static void main(String[] args) {
        String sapclient = "800";           //要登录的客户端
        String userid = "HR_CON_ADM";       //用户名
        String password = "SAP@s4dev";      //登录口令
        String hostname = "192.168.200.11"; //系统的IP地址
        String systemnumber = "00";         //系统编号
        String Language = "ZH";             //系统语言
        String sapRouter = "";
        String group = "S4P";
        String r3name = "S4P";
        String mshost = "192.168.200.11";
        Properties logonProperties = new Properties();
        logonProperties.setProperty(DestinationDataProvider.JCO_ASHOST,hostname);
        logonProperties.setProperty(DestinationDataProvider.JCO_CLIENT,sapclient);
        logonProperties.setProperty(DestinationDataProvider.JCO_SYSNR,systemnumber);
        logonProperties.setProperty(DestinationDataProvider.JCO_USER,userid);
        logonProperties.setProperty(DestinationDataProvider.JCO_PASSWD,password);
        logonProperties.setProperty(DestinationDataProvider.JCO_LANG,Language);
        logonProperties.setProperty(DestinationDataProvider.JCO_R3NAME,r3name);
        logonProperties.setProperty(DestinationDataProvider.JCO_GROUP,group);
        logonProperties.setProperty(DestinationDataProvider.JCO_MSHOST,mshost);
        JCO.Client myConnection = JCO.createClient(logonProperties);

        myConnection.connect();

        if (myConnection != null && myConnection.isAlive()) {
            System.out.println("测试连接sap成功!");
        } else {
            System.out.println("测试连接sap失败!");
        }
        myConnection.disconnect();
    }
}
